package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 处理配置实体类
 *
 * 根据E-04-02图像处理子模块数据库设计实现
 * 存储图像处理的配置参数信息。
 *
 * @author System
 * @version 2.0.0
 * @since 2025-11-15
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ProcessingConfig {

    /**
     * 配置ID，主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 配置标识
     */
    @Column(name = "config_id", length = 64, unique = true)
    private String configId;

    /**
     * 配置名称
     */
    @Column(name = "config_name", length = 100, nullable = false)
    private String configName;

    /**
     * 配置类型
     */
    @Column(name = "config_type", length = 30, nullable = false)
    private String configType;

    /**
     * 配置版本
     */
    @Column(name = "config_version", length = 10, nullable = false)
    private String configVersion;

    /**
     * 是否激活
     */
    @Column(name = "is_active")
    private Boolean isActive;

    /**
     * 是否默认
     */
    @Column(name = "is_default")
    private Boolean isDefault;

    /**
     * 配置描述
     */
    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    // 预处理配置

    /**
     * 启用几何校正
     */
    @Column(name = "enable_geometry_correction")
    private Boolean enableGeometryCorrection;

    /**
     * 几何校正配置
     */
    @Column(name = "geometry_correction_config", columnDefinition = "TEXT")
    private String geometryCorrectionConfig;

    /**
     * 启用色彩调整
     */
    @Column(name = "enable_color_adjustment")
    private Boolean enableColorAdjustment;

    /**
     * 色彩调整配置
     */
    @Column(name = "color_adjustment_config", columnDefinition = "TEXT")
    private String colorAdjustmentConfig;

    /**
     * 启用噪声降低
     */
    @Column(name = "enable_noise_reduction")
    private Boolean enableNoiseReduction;

    /**
     * 噪声降低配置
     */
    @Column(name = "noise_reduction_config", columnDefinition = "TEXT")
    private String noiseReductionConfig;

    // 标准化配置

    /**
     * 目标DPI
     */
    @Column(name = "target_dpi", precision = 5, scale = 1)
    private Double targetDpi;

    /**
     * 目标格式
     */
    @Column(name = "target_format", length = 10)
    private String targetFormat;

    /**
     * 最大宽度
     */
    @Column(name = "max_width")
    private Integer maxWidth;

    /**
     * 最大高度
     */
    @Column(name = "max_height")
    private Integer maxHeight;

    /**
     * 压缩质量
     */
    @Column(name = "compression_quality")
    private Integer compressionQuality;

    /**
     * 启用水印
     */
    @Column(name = "enable_watermark")
    private Boolean enableWatermark;

    /**
     * 水印配置
     */
    @Column(name = "watermark_config", columnDefinition = "TEXT")
    private String watermarkConfig;

    // 质量控制配置

    /**
     * 质量阈值配置
     */
    @Column(name = "quality_thresholds", columnDefinition = "TEXT", nullable = false)
    private String qualityThresholds;

    /**
     * 启用自动增强
     */
    @Column(name = "enable_auto_enhancement")
    private Boolean enableAutoEnhancement;

    /**
     * 自动增强配置
     */
    @Column(name = "auto_enhancement_config", columnDefinition = "TEXT")
    private String autoEnhancementConfig;

    /**
     * 创建人
     */
    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    /**
     * 更新人
     */
    @Column(name = "updated_by", length = 64)
    private String updatedBy;

    // 审计字段

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 版本号（乐观锁）
     */
    @Version
    @Column(name = "version")
    private Integer version = 0;

    /**
     * 逻辑删除标记
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;
}